package receivers;

import com.rabbitmq.client.*;

import java.io.IOException;

public class SimpleReceiver extends Receiver{
    public SimpleReceiver(Connection connection, String queueName, boolean persistence, String exchangeName, String exchangeType, String routingKey) throws IOException {
        super(connection, queueName, persistence, exchangeName, exchangeType, routingKey);
    }

    @Override
    public void receive(Consumer consumer) throws IOException {
        //一次只接受一条未确认的消息
        channel.basicQos(1);
        channel.queueDeclare(queueName, persistence,false,false,null);
        channel.basicConsume(queueName,false, consumer);
    }
}
